# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=dynamorio
pkgver=9.0.19046
pkgrel=1
groups=('blackarch' 'blackarch-binary' 'blackarch-reversing')
pkgdesc='A dynamic binary instrumentation framework.'
url='https://github.com/DynamoRIO/dynamorio'
arch=('x86_64')
license=('BSD')
source=("https://github.com/DynamoRIO/dynamorio/releases/download/cronbuild-$pkgver/DynamoRIO-Linux-$pkgver.tar.gz")
sha512sums=('4fd65ab5bd1bb84beba00da3de9a0021f5ca83a8a709d1e3a5f2601055e845551aa52442ee8d4c77b2b50a31a0d0f8d493dbcf1d5c8f29f54854d5c4dd5a96c4')

prepare() {
  cd "$srcdir/DynamoRIO-Linux-$pkgver"

  rm -rf bin32/ lib32/ bin64/*.debug cmake/
}

package() {
  cd "$srcdir/DynamoRIO-Linux-$pkgver"

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 License.txt "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
  cp -a --no-preserve=ownership * "$pkgdir/usr/share/$pkgname"

  _TO_LINK='drconfig drinject drloader drrun nudgeunix'

  for executable in $_TO_LINK; do
    ln -sf /usr/share/$pkgname/bin64/$executable "$pkgdir/usr/bin/$executable"
  done
}

